// pages/mine/mine.js
Page({
  data: {
    userInfo: {
      avatarUrl: '/public/images/noLoginUser.jpg'
    },
    hasUserInfo: false,
  },
  onLoad(options) {
    // 检查用户信息
    const userInfo = wx.getStorageSync('userInfo');
    if (userInfo) {
      this.setData({
        userInfo: userInfo,
        hasUserInfo: true
      });
    }
  },

  getUserWeAvatar(e) {
    const avatarUrl = e.detail.avatarUrl
    // 存储用户头像
    wx.setStorageSync('avatarUrl', avatarUrl)
    this.setData({
      userInfo:{
        avatarUrl,
      }
    })
  },

  goToLogin() {
    wx.navigateTo({
      url: '/pages/login/login' 
    });
  },

  goToUserInfor() {
    wx.navigateTo({
      url: '/pages/user-info/user-info' 
    });
  },

  goToReferralRecord() {
    wx.switchTab({
      url: '/pages/referralRecord/referralRecord',
    });
  },

  goToMessage() {
    wx.navigateTo({
      url: '/pages/message/message'
    });
  }
})